package com.emex.app.stuff.security.ui;

import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import org.openide.awt.StatusLineElementProvider;
import org.openide.util.lookup.ServiceProvider;

/**
 * This class represents status bar line with username.
 *
 * @author Pavel Sedov
 */
@ServiceProvider(service = StatusLineElementProvider.class)
public class UserInfoStatusLine implements StatusLineElementProvider {

    private static JLabel username = new JLabel("  ");
    private JPanel panel = new JPanel(new BorderLayout());
    
    public static void setUsername(final String usernameString) {
        username.setText(" " + usernameString + " ");
    }

    public UserInfoStatusLine() {
        panel.add(new JSeparator(SwingConstants.VERTICAL), BorderLayout.WEST);
        panel.add(username, BorderLayout.CENTER);
    }

    @Override
    public Component getStatusLineElement() {
        return panel;
    }
}
